
import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set from '@dfeidao/atom-web/local/set';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import whoami from '../../atom/whoami';
import p001 from './p001';


export default async function a002(fd: IFeidaoAiBrowserComponent) {
	// todo


	const res = await whoami(fd);
	const a = res.params;
	const staff_no = a.staff_no;
	set(fd, 'staff_no', staff_no);
	const productid = a.productid;
	set(fd, 'productid', productid);
	console.log(staff_no);
	const res2 = await nodejs<{ headimg: string }>('common/zjc-000003/s002', { staff_no, productid });
	console.log(res2);
	const name = a.staff_name;
	const headImg = res2 ? res2.headimg : '';
	const dataMessage = [{ staff_name: name, headimg: headImg, productid }];
	console.log(dataMessage);
	render(fd, dataMessage, p001, 'p001', 'inner');



	const purse = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-id="' + fd.data.params.url + '"]');

	if (purse) {
		const others = document.querySelectorAll('[data-feidao-id2="common"]');
		others.forEach((v) => {
			if (v === purse) {
				v.classList.add('bg-themef');
			} else {
				v.classList.remove('bg-themef');
			}

		});

	} else {
		const urlStr = document.URL;
		if (urlStr.search("mine-purse") !== -1) {
			const purse1 = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-id="mine-purse"]');
			purse1.classList.add('bg-themef');
			const others = document.querySelectorAll('[data-feidao-id2="common"]');
			others.forEach((v) => {
				if (v === purse1) {
					v.classList.add('bg-themef');
				} else {
					v.classList.remove('bg-themef');
				}

			});
		} else if (urlStr.search("send") !== -1 || urlStr.search("send-email") !== -1 || urlStr.search("recieve-email") !== -1 || urlStr.search("retrieve-email") !== -1 || urlStr.search("email-details") !== -1) {
			const purse2 = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-id="recieve-email"]');
			purse2.classList.add('bg-themef');
			const others = document.querySelectorAll('[data-feidao-id2="common"]');
			others.forEach((v) => {
				if (v === purse2) {
					v.classList.add('bg-themef');
				} else {
					v.classList.remove('bg-themef');
				}

			});
		} else if (urlStr.search("mine-information") !== -1) {
			const information = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-id="mine-information"]');
			information.classList.add('bg-themef');
			const others = document.querySelectorAll('[data-feidao-id2="common"]');
			others.forEach((v) => {
				if (v === information) {
					v.classList.add('bg-themef');
				} else {
					v.classList.remove('bg-themef');
				}

			});

		} else if (urlStr.search("mine-award") !== -1) {
			const award = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-id="mine-award"]');
			award.classList.add('bg-themef');
			const others = document.querySelectorAll('[data-feidao-id2="common"]');
			others.forEach((v) => {
				if (v === award) {
					v.classList.add('bg-themef');
				} else {
					v.classList.remove('bg-themef');
				}

			});

		} else if (urlStr.search("mine-publish") !== -1) {
			const publish = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-id="mine-publish"]');
			publish.classList.add('bg-themef');
			const others = document.querySelectorAll('[data-feidao-id2="common"]');
			others.forEach((v) => {
				if (v === publish) {
					v.classList.add('bg-themef');
				} else {
					v.classList.remove('bg-themef');
				}

			});

		} else if (urlStr.search("mine-collect") !== -1) {
			const collect = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-id="mine-collect"]');
			collect.classList.add('bg-themef');
			const others = document.querySelectorAll('[data-feidao-id2="common"]');
			others.forEach((v) => {
				if (v === collect) {
					v.classList.add('bg-themef');
				} else {
					v.classList.remove('bg-themef');
				}

			});

		} else if (urlStr.search("manager") !== -1) {
			const manager = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-id="manager"]');
			manager.classList.add('bg-themef');
			const others = document.querySelectorAll('[data-feidao-id2="common"]');
			others.forEach((v) => {
				if (v === manager) {
					v.classList.add('bg-themef');
				} else {
					v.classList.remove('bg-themef');
				}

			});

		} else if (urlStr.search("staff") !== -1) {
			const staff = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-id="staff"]');
			staff.classList.add('bg-themef');
			const others = document.querySelectorAll('[data-feidao-id2="common"]');
			others.forEach((v) => {
				if (v === staff) {
					v.classList.add('bg-themef');
				} else {
					v.classList.remove('bg-themef');
				}

			});

		} else if (urlStr.search("mine-integral") !== -1) {
			const integral = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-id="mine-integral"]');
			integral.classList.add('bg-themef');
			const others = document.querySelectorAll('[data-feidao-id2="common"]');
			others.forEach((v) => {
				if (v === integral) {
					v.classList.add('bg-themef');
				} else {
					v.classList.remove('bg-themef');
				}

			});

		}
	}






}
